package bintree.map_set.LeetCode;

import java.util.HashSet;
import java.util.Set;

//771. 宝石与石头
public class Num771_numJewelsInStones {
    public static int numJewelsInStones(String jewels, String stones) {
        //用Set集合特性保存不同值
        Set<Character> set = new HashSet<>();
        //把宝石类型以每个字符录入
        for (int i = 0; i < jewels.length(); i++) {
            char ch = jewels.charAt(i);
            set.add(ch);
        }//现在Set集合里面就保存了各种宝石类型
        int conut = 0;//用来统计的个数的
        for (int i = 0; i < stones.length(); i++) {
             char ch = stones.charAt(i);
             if(set.contains(ch)){
                 conut ++;
             }
        }

    return conut;
    }

    public static void main(String[] args) {
        String jewels = "aA";
        String stones = "aAAbbb";

        System.out.println(numJewelsInStones(jewels, stones));

    }
}
